package com.baomidou.mybatisplus.samples.quickstart.service;

import com.baomidou.mybatisplus.samples.quickstart.chain.UrlParamsHandlerChain;
import com.baomidou.mybatisplus.samples.quickstart.entity.ApiUrlParam;
import com.baomidou.mybatisplus.samples.quickstart.entity.User;
import com.baomidou.mybatisplus.samples.quickstart.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zhang
 */
@Service
public class UserService{
    @Resource
    private UserMapper userMapper;

    @Autowired
    UrlParamsHandlerChain urlParamsHandlerChain;

    public List<User> getByName() {
        List<User> userList = userMapper.selectList(null);
        return userList;
    }

    public String getUserUrl(){
        String handledUrl = urlParamsHandlerChain.handle(ApiUrlParam.builder().url("http://baidu.com").userId("zhangsanfeng").build());
        return handledUrl;
    }

}
